<template>
  <div id="teachercard">
    <div class="main">
      <!-- 头像 -->
      <Avatar shape="circle" size="large" class="headerimg" :src="teacherInfo.avatar" />
      <Row>
        <Col span="24" style="height:30px;background-color:#f5f5f5">&nbsp</Col>
      </Row>
      <Row>
        <Col span="24" class="lineheight" :style="'background-color:'+teacherInfo.backgcolor"></Col>
      </Row>
      <Row>
        <Col span="24" class="teacherInfo">
        <!-- 教师展示信息 -->
          <p class="teacherName">{{teacherInfo.name}}</p>
          <p class="teacherPosit">{{teacherInfo.position}}</p>
          <p class="teacherDesc">{{teacherInfo.description|textFormation}}</p>
        </Col>
      </Row>
    </div>
  </div>
</template>

<script>
//导入iview-ui组件
import { Row, Col, Avatar } from "view-design";
//导入vue
import Vue from "vue";
//这里做个了一个测试在不同浏览器显示不同大小的过滤器, 把描述文字达到一定长度显示省略号
Vue.filter("textFormation", val => {
  //终端判断
  // let ua = navigator.userAgent.toLowerCase();
  // //Android终端
  // let isAndroid = ua.indexOf("Android") > -1 || ua.indexOf("Adr") > -1; //Ios终端
  // let isiOS = !!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  // if (isWeixinBrowser()) {
  //   console.log("VX");
  // } else {
  //   if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
  //     //Ios
  //     console.log("iPhone|iPad|iPod|iOS");

  //     if (navigator.userAgent.indexOf("10_3_1") != -1) {
  //       console.log("iPhone5SE");
  //       return val.substr(0, 100) + "...";
  //     }
  //   } else if (/(Android)/i.test(navigator.userAgent)) {
  //     //Android终端
  //     console.log(navigator.userAgent);
  //   }
  // }

  // function isWeixinBrowser() {
  //   return /micromessenger/.test(ua) ? true : false;
  // }

  return val.substr(0, 138) + "...";
});
export default {
  name: "teachercard",
  //组件注册
  components: {
    Row,
    Col,
    Avatar
  },
  //传入属性
  props: ["teacherInfo"],
  data() {
    return {};
  },
  computed: {},
  watch: {},
  methods: {},
  created() {},
  mounted() {},
  beforeCreate() {}, //生命周期 - 创建之前
  beforeMount() {}, //生命周期 - 挂载之前
  beforeUpdate() {}, //生命周期 - 更新之前
  updated() {}, //生命周期 - 更新之后
  beforeDestroy() {}, //生命周期 - 销毁之前
  destroyed() {}, //生命周期 - 销毁完成
  activated() {} //如果页面有keep-alive缓存功能，这个函数会触发
};
</script>

<style scoped>
/* 局部样式UI修改 */
.main {

  height: 425px;
}
.teacherInfo {
  background-color: #fff;
  text-align: center;
  padding: 90px 15px 25px;
  box-shadow: 0 0 12px 1px #d0d0d0;
  height: 380px;
  border-radius: 3px;
}
.teacherName {
  font-size: 18px;
  padding-bottom: 15px;
}
.teacherPosit {
  font-size: 10px;
  color: #9d9d9d;
  padding-bottom: 15px;
}
.teacherDesc {
  font-size: 14px;
  line-height: 20px;
  letter-spacing: 1px;
}
.headerimg {
  position: absolute;
  width: 95px;
  height: 95px;
  left: 32.3333333%;
  top: 10px;
  z-index: 2;
}
.lineheight {
  height: 4px;
  border-top-right-radius: 3px;
  border-top-left-radius: 3px;
}
</style>